import tensorflow as tf
import time
a = tf.random.normal([100,100], mean=1, stddev=1)
b = tf.random.normal([100,100], mean=1, stddev=1)
print(a)
print(b)


start_time2 = time.time()
with tf.device("/gpu:0"):
    re2 = tf.matmul(a, b)
end_time2 = time.time()
print("gpu耗时：", (end_time2-start_time2)*1000)

start_time1 = time.time()
with tf.device("/cpu:0"):
    re = tf.matmul(a, b)
end_time1 = time.time()
print("cpu耗时：", (end_time1-start_time1)*1000)


#import tensorflow as tf
#print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))

#print(tf.linalg.band_part(tf.ones([2048, 2048]), -1, 0))